package com.bootdo.xiao.suggest;

/**
 * @Auther: liuj
 * @Date: 2019/6/17 17:02
 * @Description:建议38：使用静态内部类提高封装性
 * 1、加强了类的封装性
 * 2、提高了代码的可读性
 */
public class Suggest38 {
    private String name;
    private int age;
    private Home home;

    public Suggest38(String _name, int _age){
        name = _name;
        age = _age;
    }

    public static class Home{
        private String address;
        private String tel;

        public Home(String _address, String _tel){
            address = _address;
            tel = _tel;
        }

        public String getAddress() {
            return address;
        }

        public void setAddress(String address) {
            this.address = address;
        }

        public String getTel() {
            return tel;
        }

        public void setTel(String tel) {
            this.tel = tel;
        }

        @Override
        public String toString() {
            return "Home{" +
                    "address='" + address + '\'' +
                    ", tel='" + tel + '\'' +
                    '}';
        }
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Home getHome() {
        return home;
    }

    public void setHome(Home home) {
        this.home = home;
    }


    @Override
    public String toString() {
        return "Suggest38{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public static void main(String[] args){
        Suggest38 suggest38 = new Suggest38("liujia", 25);

        Home home = new Suggest38.Home("ssssssss","545645");
        suggest38.setHome(new Suggest38.Home("太原市","18834825727"));

        System.out.println(suggest38.toString());
        System.out.println(suggest38.home.toString());
    }
}
